package net.zoneland.greenleaf.log.service;


import org.apache.log4j.Logger;

import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.UUID;

import net.zoneland.greenleaf.log.entity.Log_method_call;
import net.zoneland.greenleaf.log.dao.Log_method_callDao;

import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * LOG_METHOD_CALL[服务调用日志]表操作Serfice实现类

 * 类   名：Log_method_callServiceImpl<br/>
 * 表   名：LOG_METHOD_CALLSERVICEIMPL<br/>
 * 注   释：<br/>
 * 作   者：GREENLEAF<br/>
 * 单   位：浙江兰德纵横网络技术有限公司<br/>
 * 日   期：2014-09-03 20:35:13
**/
@Service("log_method_callService")
public class Log_method_callServiceImpl implements Log_method_callServiceI { 

	public static Logger logger = Logger.getLogger(Log_method_callServiceImpl.class);
	
	/**
	 * 自动注入DAO对象
	**/
	@Autowired
	private Log_method_callDao log_method_callDao;
	
	/**
	 * 新增或者更新数据方法接口
	**/
	@Override
	public boolean addOrUpdate(Log_method_call log_method_call){
		try {
			Log_method_call log_method_call_temp = null;
			if (log_method_call == null) {
				logger.warn(Log_method_call.class.getName() + "对象参数信息为Empty！");
				return false;
			}
			Map <String, Object> map = new HashMap();
			map.put("id", log_method_call.getId());
			List list  = log_method_callDao.getList(map);
			if(list!=null &&list.size()>0){
				//说明 数据已经存在,直接更新数据
				log_method_callDao.edit(log_method_call);
				return true;
			}else{
				//说明 数据目前不存在
				log_method_call.setId( UUID.randomUUID() + "" );
				log_method_callDao.add(log_method_call);
				return true;
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	/**
	 * 新增数据方法实现
	**/
	@Override
	public boolean add(Log_method_call log_method_call){
		try {
			log_method_call.setId( UUID.randomUUID() + "" );
			log_method_callDao.add( log_method_call );
			return true;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	/**
	 * 更新数据方法实现
	**/
	@Override
	public boolean update(Log_method_call log_method_call){
		try {
			log_method_callDao.edit( log_method_call );
			return true;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	/**
	 * 查询数据方法实现
	**/
	@Override
	public Log_method_call get( Map <String, Object> map ) {
		try {
			return log_method_callDao.get( map );
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	/**
	 * 查询数据方法实现（列表）
	**/
	@Override
	public List<Log_method_call> getList(Map <String, Object> map){ 
		List<Log_method_call> list = null;
		try {
			list = log_method_callDao.getList( map );
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		return list;
	}
	
	/**
	 * 查询数据总数方法实现
	**/
	@Override
	public int getListCount(Map <String, Object> map) { 
		int count = 0;
		try {
			count = log_method_callDao.getListCount( map );
		} catch (Exception e) {
				count = 0;
		}
		return count;
	}
	
	/**
	 * 数据删除方法实现
	**/
	@Override
	public boolean delete(Map <String, Object> map){ 
		boolean flag = false;
		try {
			log_method_callDao.delete( map );
			flag = true;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		return flag;
	}
	
}
